package com.toubutu.audio;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.config.rules.DbColumnType;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
import com.toubutu.audio.common.BasePo;

import java.sql.Types;
import java.util.Collections;

/**
 * @author 戒躁
 * @date 2024/1/8
 */
public class GenerateCode {
    public static void main(String[] args) {
        FastAutoGenerator.create("jdbc:mysql://rm-cn-o493jo3l9000jqto.rwlb.rds.aliyuncs.com:3306/audio", "toubutu", "@Zhu20190204")
                .globalConfig(builder -> {
                    builder.author("戒躁") // 设置作者
                            .enableSwagger() // 开启 swagger 模式
                            .fileOverride() // 覆盖已生成文件
                            .outputDir("D://toubutu/generate"); // 指定输出目录
                })
                .packageConfig(builder -> {
                    builder.parent("com.toubutu") // 设置父包名
                            .moduleName("audio") // 设置父包模块名
                            .pathInfo(Collections.singletonMap(OutputFile.xml, "D://toubutu/generate")); // 设置mapperXml生成路径
                })
                .strategyConfig(builder -> {
                    builder.addInclude("collection") // 设置需要生成的表名
                            .addTablePrefix("t_", "c_")// 设置过滤表前缀
                            .build()
                            .entityBuilder()
                            .enableLombok()
                            .superClass(BasePo.class)
                            .addIgnoreColumns("create_time","update_time","create_user_id","update_user_id","is_delete")
                            .build()
                            .mapperBuilder()
                            .enableMapperAnnotation()
                            .build()
                            .serviceBuilder()
                            .formatServiceFileName("%sService")
                            .formatServiceImplFileName("%sServiceImpl")
                            .build()
                    ;
                })
                .templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板，默认的是Velocity引擎模板
                .execute();
    }
}
